#查看版本和摘取镜像
# kubectl version 服务端版本 

pullimages.sh修改版本号

#修改hostname，配置hosts

echo k8s-master > /etc/hostname
echo k8s-node1 > /etc/hostname
echo k8s-node2 > /etc/hostname
# reboot或重启systemd-hostnamed服务生效
systemctl restart systemd-hostnamed


# 禁用防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
firewall-cmd --state
echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables

# 安装kubeadm、kubectl、kubelet
yum install -y kubectl-1.16.0-0 kubeadm-1.16.0-0 kubelet-1.16.0-0

#简化linux命令
echo alias kc="kubectl" > ~/.bashrc
source ~/.bashrc

# 启动kubelet服务
systemctl enable kubelet && systemctl start kubelet



kubeadm join 192.168.0.243:6443 --token d8fl1w.utw6yqp74r2chz5q \
	--discovery-token-ca-cert-hash sha256:15e9f975a8d813359eee305181610eb18d1db5592452af7d52742e1611435a4b
	
	
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# 复制/etc/kubernetes/admin.conf 到node节点,并执行
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile
# not done maybe:The connection to the server localhost:8080 was refused - did you specify the right host or port?
一，重置k8s
1，主节点：
kubectl delete node k8s-master k8s-node1 
kubeadm reset
rm -rf $HOME/.kube /var/log/containers /var/log/pods
2，从节点
kubeadm reset
rm -rf $HOME/.kube /var/log/containers /var/log/pods

二，更换网络插件
卸载flannel：
在master节点删除flannel
kubectl delete -f kube-flannel.yml
#ifconfig cni0 down
#ip link delete cni0
#ifconfig flannel.1 down
#ip link delete flannel.1
#rm -rf /var/lib/cni/
#rm -f /etc/cni/net.d/*
systemctl restart kubelet
重启kubelet
sytemctl restart kubelet
安装calico：
wget  https://docs.projectcalico.org/manifests/calico.yaml
kubectl apply -f calico.yaml
docker images|grep ^ calico


kubeadm reset -f
rm -rf $HOME/.kube /var/log/containers /var/log/pods
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
rm -rf /var/lib/cni/
rm -f /etc/cni/net.d/*
systemctl restart kubelet
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
reboot